import useLayoutTabsStore from '@/ui/antd/store/useLayoutTabsStore'
import viewRouterService from '@/ui/antd/service/router/viewRouterService'

class layoutTabsService {
	getTabs = (): string[] => {
		const tabs: string[] = useLayoutTabsStore.getState().tabs
		if (tabs.length === 0) {
			tabs.push(viewRouterService.getDefaultRoute().path)
		}
		return tabs
	}

	setTabs = (tabs: string[]): void => {
		useLayoutTabsStore.setState({ tabs: tabs })
	}

	refreshCurrentTab = (): void => {
		useLayoutTabsStore.setState({ refresh: true })
		setTimeout(() => {
			useLayoutTabsStore.setState({ refresh: false })
		}, 200)
	}

	getRefreshRef = (): boolean => {
		return useLayoutTabsStore.getState().refresh
	}
}

export default new layoutTabsService()
